<template>
  <div class="o-content-box">
    <div class="mask"></div>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多啦"
      @load="load_more"
    >
      <ul class="orderTaking_box">
        <li v-for="(obj, ind) in glist" :key="ind" @click="senddetail(obj)">
          <router-link :to="'/detail/' + obj.takeOrderId">
            <div class="Taking_box">
              <div class="T-order_title">
                <span>公共</span>
                <a href="#">{{ obj.takeOrderTitle }}</a>
              </div>
              <div class="T-game-info">
                <span>{{ obj.gameInfo }}</span>
                <div class="order_price">
                  ￥<span>{{ obj.totalPrice }}.</span>00
                </div>
              </div>
              <div class="T-bzj-time">{{ obj.bondAndTrainTime }}</div>
              <div class="T-fbz-info">{{ obj.publiserInfo }}</div>
            </div>
          </router-link>
        </li>
      </ul>
    </van-list>
  </div>
</template>

<script>
import axios from "axios";
import { mapMutations, mapState } from "vuex";
export default {
  data() {
    return {
      gamelist: [],
      ref: "index",
      num: this.itemindex,
      loading: false, //加载状态
      finished: false, //是否加载
      page: 1, //页数
      limit: 15, //条数
    };
  },
  watch: {
    itemindex() {
      this.num = this.itemindex;
      console.log(this.num);
    },
  },
  computed: {
    ...mapState({
      itemindex: (state) => state.orderlist.itemindex,
      glist: (state) => state.orderlist.orderlist,
    }),
  },
  methods: {
    ...mapMutations({
      list: ["initList"],
    }),
    senddetail(detailinfo) {
      this.$store.commit("orderlist/getDetailInfoMut", detailinfo);
    },
    load_more: function () {
      this.page += 1; //页数+1
      this.onLoad();
    },
    onLoad() {
      let data = {
        page: this.page,
        pageSize: this.limit,
      };
      axios
        .post(
          "/dl/wap/getMoreAllTakeOrderListOrCondition?keyword=&pageIndex=1&gameId=0&areaId=0&serverId=0&orderGrade=&sortCondition=&minPrice=&maxPrice=&dlDoubleStartScore=&dlDoubleEndScore=",
          data
        )
        .then((res) => {
          console.log(res);
          if ((res.status = 200)) {
            // 加载状态结束
            this.loading = false;
            this.gamelist = this.gamelist.concat(res.data.takeOrderList); //追加数据
            if (
              res.data.page == res.data.pageNum ||
              res.data.takeOrderList.length == 0
            ) {
              //数据全部加载完成
              this.finished = true;
            } else {
              this.finished = false;
            }
          }
        });
    },
  },
};
</script>

<style src="../assets/css/ptitemlist.css" scoped>
</style>

<style lang="less" scoped>
</style>